﻿namespace ScrumLite.WebUx.Tests
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using ScrumLite.WebUx.Controllers;
    using ScrumLite.WebUx.Models;
    using System.Security.Permissions;
    using System.Web.Mvc;

    /// <summary>
    /// Summary description for HomeControllerFixture
    /// </summary>
    [TestClass]
    public class HomeControllerFixture
    {
        [TestMethod]
        public void ShouldReturnHomeView()
        {
            TestableHomeController controller = new TestableHomeController();
            controller.Index();

            Assert.AreEqual("Home", controller.ViewToShow);
            Assert.IsInstanceOfType(controller.DataToShow, typeof(ContextViewData));
        }
    }

    public class TestableHomeController : HomeController
    {
        public object DataToShow { get; set; }
        public string ViewToShow { get; set; }

        public TestableHomeController() :
            base()
        {
        }
        
        [SecurityPermission(SecurityAction.LinkDemand, Unrestricted = true)]
        protected override void RenderView(string viewName, string masterName, object viewData)
        {
            ViewToShow = viewName;
            DataToShow = viewData;
        }
    }
}
